package com.qkl.xiatang.app.entity.video;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

@Data
@TableName(value = "dahua_config")
public class DahuaConfigEntity {

    @TableId(type= IdType.AUTO)
    private Integer id;

    private String productName;

    private String productId;

    private String memo;

    private String accessKey;

    private String secretAccessKey;

    private String apiDomain;

    private String accessToken;

    private Integer validitySeconds;

    private Long tokenTime;

    private Date createTime;


    public boolean tokenValidity(){
        if(StringUtils.isEmpty(accessToken) || null == validitySeconds || validitySeconds == 0 || null == tokenTime || tokenTime == 0){
            return true;
        }
        return (System.currentTimeMillis() - tokenTime )/1000 >= validitySeconds;
    }

}